////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////@

skimon = {
	host: 'http://localhost/fantasmatakia/skimon',
}

skimon.oriste = function(skiniko) {
	Log.print('listening port ' + globals.monitorPort + ' for http requests');
	skimon.server = server.http.createServer(function(request, response) {
		response.writeHead(200, {
			'Access-Control-Allow-Origin': '*',
			'Content-type': 'text/json',
		});

		response.write('{');

		response.write('pektis:{');
		skiniko.pektisWalk(function(login, pektis) {
			response.write(globals.json(login) + ':' + JSON.stringify(pektis) + ',');
		});
		response.write('},');

		response.write('trapezi:{');
		skiniko.trapeziWalk(function(kodikos, trapezi) {
			var tablo = trapezi.tabloGet();
			delete trapezi.skiniko;
			delete trapezi.tablo;
			response.write(kodikos + ':' + JSON.stringify(trapezi) + ',');
			trapezi.skiniko = skiniko;
			trapezi.tablo = tablo;
		});
		response.write('},');

		response.write('sinedria:{');
		skiniko.sinedriaWalk(function(pektis, sinedria) {
			delete sinedria.skiniko;
			response.write(globals.json(pektis) + ':' + JSON.stringify(sinedria) + ',');
			sinedria.skiniko = skiniko;
		});
		response.write('},');

		response.end('}');
	}).listen(globals.monitorPort);
}

skimon.close = function() {
	Log.print('stop listening port ' + globals.monitorPort);
	skimon.server.close();
}
